//
//  HECaseReportCell.m
//  HealthElderly
//
//  Created by 吴欧 on 2021/6/18.
//  Copyright © 2021 honglutec. All rights reserved.
//

#import "HECaseReportCell.h"
#import "HECaseReportModel.h"

@interface HECaseReportCell ()

@property (nonatomic, strong) UIImageView *iconView;
@property (nonatomic, strong) UILabel *titleLb;
@property (nonatomic, strong) UILabel *crateTimeLb;
@property (nonatomic, strong) UIView *warp;

@end

@implementation HECaseReportCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.contentView.backgroundColor = CViewBgColor;
        [self initUI];
    }
    return self;
}

- (void)initUI {
    
    UIView *warp = [UIView new];
    warp.backgroundColor = KWhiteColor;
    warp.layer.cornerRadius = 10;
    _warp = warp;
    [self.contentView addSubview:warp];
    
    [warp mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).mas_offset(10);
        make.left.equalTo(self.contentView).mas_offset(10);
        make.right.equalTo(self.contentView).mas_offset(-10);
        make.height.mas_greaterThanOrEqualTo(110);
        make.bottom.equalTo(self.contentView).mas_offset(-0);
    }];
    
    // 图片
    _iconView = [UIImageView new];
    _iconView.image = IMAGE_NAMED(@"noImage");
    _iconView.contentMode = UIViewContentModeScaleAspectFill;
    _iconView.layer.masksToBounds = YES;
    _iconView.layer.cornerRadius = 8;
    [warp addSubview:_iconView];

    // 姓名
    _titleLb = [UILabel new];
    _titleLb.text = @"-";
    _titleLb.font = DYBlodFont(20);
    _titleLb.textColor = CNavLightBlackColor;
    _titleLb.numberOfLines = 2;
    [warp addSubview:_titleLb];
     

    // 描述
    _crateTimeLb = [UILabel new];
    _crateTimeLb.text = @"-";
    _crateTimeLb.font = DYFont(15);
    _crateTimeLb.textColor = CNavDargGrayColor;
    _crateTimeLb.numberOfLines = 2;
    [warp addSubview:_crateTimeLb];
    

    [_iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(warp).offset(15);
        make.left.equalTo(warp).mas_offset(15);
        make.width.height.mas_offset(80);
        make.bottom.equalTo(warp).offset(-15);
    }];


    [_titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(warp).offset(15);
        make.left.equalTo(_iconView.mas_right).mas_offset(10);
        make.right.equalTo(warp).mas_offset(-10);
    }];
   
    [_crateTimeLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_titleLb.mas_left);
        make.right.equalTo(warp).mas_offset(-10);
        make.bottom.equalTo(warp.mas_bottom).mas_offset(-15);
    }];
}

- (void)configCellWithModel:(HECaseReportModel *)model {
    [_iconView sd_setImageWithURL:[NSURL URLWithString:model.cover] placeholderImage:IMAGE_NAMED(@"noImage")];
    _titleLb.text = model.case_name;
    _crateTimeLb.text = [NSString stringWithFormat:@"上传时间：%@", [NSDate timestampToDate:model.create_date formaterMode: NSDateFormaterModeDay]];
}

@end
